package _base0to1;

/**
 * 1491. 去掉最低工资和最高工资后的工资平均值
 */
public class No1491 {
    public double average(int[] salary) {
        int max = salary[0], min = salary[0], sum = 0;
        for (int i : salary) {
            if (i > max) max = i;
            else if (i < min) min = i;
            sum += i;
        }
        int n = salary.length;
        return (double) (sum - max - min) / (n - 2);
    }
}
